#!/usr/bin/env python


from django import template

from accounts.models import CustomUser
from cmdb_auths.models import AuthNode

register = template.Library()


@register.filter(name='node_count')
def node_count(user):
    user = CustomUser.objects.get(username=user)
    user_count = AuthNode.objects.filter(user_name=user).count()

    return user_count
